
<?php	
	//firsttime
	if(!empty($_POST)){
		$username = isset($_POST['txtusername']) ? $_POST['txtusername'] : '';
		$password = isset($_POST['txtpassword']) ? $_POST['txtpassword'] : '';
		
		$acc = new Account();
		$result = $acc->login($username, $password);
		
		if($result){
			echo '<script> location.reload() </script>';
		}
	}
	
?>


<div class="modal modal-login">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<!--<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>-->
				<h4 class="modal-title">Login</h4>
			</div>
			<div class="modal-body">
				<form parsley-validate class="form-horizontal" role="form" id="frmlogin" name="frmlogin" method="post" action="">
					<div class="form-group">
						<label for="username" class="col-sm-2 control-label">Username</label>
						<div class="col-sm-10">
							<input parsley-required="true" type="text" class="form-control" id="username" name="txtusername" placeholder="Username">
						</div>
					</div>
					<div class="form-group">
						<label for="txtpassword" class="col-sm-2 control-label">Password</label>
						<div class="col-sm-10">
							<input parsley-required="true" type="password" id="txtpassword" name="txtpassword" class="form-control"  placeholder="Password">
						</div>
					</div>

					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-10">
							<button type="submit" class="btn btn-default">
								Log in
							</button>

						</div>
					</div>

					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-10">
							<a href="?mod=forgotpass">Forgotten password</a>
						</div>
					</div>
				</form>
				<?php if( isset($result) && !$result): ?>
					<div class="alert alert-danger">The system could not log you on, please try again !</div>
				<?php endif; ?>

			</div>

		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div>


